package com.lvhx.springboot.springbatch.tasklet;

import com.lvhx.springboot.base.AccountAggregateUser;
import com.lvhx.springboot.base.Repository;
import com.lvhx.springboot.callservice.BaseAction;
import com.lvhx.springboot.callservice.dto.UserDeleteRequest;
import com.lvhx.springboot.entity.User;
import com.lvhx.springboot.mapper.UserMapper;
import com.lvhx.springboot.springbatch.base.Parameters;
import com.lvhx.springboot.springbatch.base.TaskletAppl;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;
import java.util.concurrent.TimeUnit;
@Slf4j
public class HelloTaskletAppl extends BaseAction implements TaskletAppl {
    private Repository<AccountAggregateUser> repository;

    public void setRepository(Repository<AccountAggregateUser> repository) {
        this.repository = repository;
    }

    @Autowired
    private UserMapper userMapper;

    @Override
    public void process(Parameters args) {

        String name = (String) args.getData("NAME");
        log.info("=====HelloTaskletAppl process 批量库配置参数NAME:{}", name);

//        UserDeleteRequest request = new UserDeleteRequest();
//        request.setMessage("callService");
//        callService("userDeleteService", request);

//        AccountAggregateUser accountAggregateUser = repository.load(1L,2L,true);
//        System.out.println(accountAggregateUser.getName());
//        accountAggregateUser.setName("lisi");

        User user = userMapper.selectByPrimaryKey(1L);
        System.out.println(user.getName());


        user.setCreateBy("WriteTasklet");
        userMapper.updateByPrimaryKeySelective(user);
    }
}
